package me.fung.rem.app.main.version

import me.fung.rem.app.encryptor
import me.fung.rem.bean.database
import me.fung.rem.bean.repo.RemItem
import me.fung.rem.bean.repo.add
import me.fung.rem.bean.repo.remItems
import org.ktorm.database.Database
import java.sql.Connection

class VersionUpdater1p1 : VersionUpdater() {
    override val targetVersion: Float = 1.1f
    override fun updateSql(db: Database, connection: Connection) {
        // RemItem ==============================================================
        """
            CREATE table  RemItem(
            id integer primary key autoincrement,
            title varchar(255),
            username varchar(255),
            password varchar(255),
            info varchar(255),
            address varchar(255),
            tag varchar(255),
            del int 
            );
        """.trimIndent().createStatementAndExecute(connection)
        // 示例
        val demo = RemItem(
            0,
            "小强",
            "123",
            encryptor().encrypt("123"),
            "左键卡片点击复制密码，右键点击卡片显示详细信息。",
            "",
            ""
        )
        database.remItems.add(demo)
    }
}
